<?php
/**
 * [商网通 System] Copyright swtshop.cn
 * QQ: 1170787711
 * Author: gj.name
 * This is NOT a freeware
*/
defined('IN_UQ') or exit('Access Denied');
class demo_uqcms extends control
{
    function index()
    {
        $this->display();
    }
    function pay()
    {
        $this->display();
    }
    function pay_post()
    {
        include 'member/api/pay.class.php';
        $ps = new pay('alipay');
        $out_trade_no = isset($_GET['trade_no']) ? $_GET['trade_no'] : exit('trade_no');
        $row = $ps->pay_run($out_trade_no);
        pr($row);
    }
    function asyn()
    {
        asynGET('index.php?m=demo&a=ce');
    }
    function ce()
    {
        $post_data = '33333';
        $outText = var_export($post_data, true);
        file_put_contents("temp/pay.txt", $outText, FILE_APPEND);
    }
    function performance()
    {
        function getCurrentTime()
        {
            list($msec, $sec) = explode(" ", microtime());
            return (double) $msec + (double) $sec;
        }
        function formatBytes($size)
        {
            $units = array(' B', ' KB', ' MB', ' GB', ' TB');
            for ($i = 0; $size >= 1024 && $i < 4; $i++) {
                $size /= 1024;
            }
            return round($size, 2) . $units[$i];
        }
        $begin = getCurrentTime();
        $mem1 = memory_get_usage();
        echo '开始内存：' . $mem1 . '(' . formatBytes($mem1) . ')<br>';
        $id = isset($_GET['id']) ? $_GET['id'] : '';
        $arr['mobile'] = '15123154';
        $a = $this->module('api')->notice('vcode', $arr);
        if ($a['error'] == '0') {
            $this->db->query("update " . table("notice") . " set status = 1 where id = " . $id);
        } else {
            $this->db->query("update " . table("notice") . " set status = 0 where id = " . $id);
        }
        $mem2 = memory_get_usage();
        echo '运行后内存：' . $mem2 . '(' . formatBytes($mem2) . ')<br>';
        $end = getCurrentTime();
        $mem_cha = $mem2 - $mem1;
        echo '占用内存：' . $mem_cha . '(' . formatBytes($mem_cha) . ')<br>';
        $spend = $end - $begin;
        echo "脚本执行时间为:" . $spend . "<br>";
    }
    function index2()
    {
    }
    function sku_post_names()
    {
        $arr = array('sku_img_id' => array('3', '10'), 'sku_img_name' => array('这个是第一个备注', '大23号+小'), 'sku_val' => array('3,38', '3,40', '10,38', '10,40'));
        $sku_name_arr = $this->sku_post_name($arr['sku_val'], $arr['sku_img_id'], $arr['sku_img_name']);
    }
}